import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its header-child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },

  // { path: '/flowBingdingAdd', component: () => import('@/views/workOrderFlow/flowBingding-child/flowBingdingAdd'), hidden: true },

  {
    path: '/flowBingdingAdd',
    component: Layout,
    redirect: '/flowBingdingAdd',
    name: 'flowBingdingAdd',
    hidden: true,
    children: [{
      path: '/flowBingdingAdd',
      name: 'flowBingdingAdd',
      component: () => import('@/views/workOrderFlow/flowBingding-child/flowBingdingAdd'),
      meta: { title: '新增绑定', icon: 'user' ,roles:['admin']}
    }]
  },

]

export const asyncRouterMap = [
  {
    path: '/cmdb',
    component: Layout,
    redirect: '/cmdb/model',
    name: 'cmdb',
    meta: { title: 'CMDB', icon: 'people3' },
    children: [
      {
        path: '/cmdb/model',
        name: 'model',
        component: () => import('@/views/cmdb/model/model'),
        meta: { title: '模型管理', icon: 'user' }
      },
      {
        path: '/cmdb/resource',
        name: 'resource',
        component: () => import('@/views/cmdb/resource/resource'),
        meta: { title: '资源管理', icon: 'user' ,roles:['admin']}
      },
    ]
  },

  {
    path: '/workOrderFlow',
    component: Layout,
    redirect: '/workOrderFlow/flowBinding',
    name: 'workOrderFlow',
    meta: { title: '工单流程', icon: 'people3' },
    children: [
      {
        path: '/workOrderFlow/flowBinding',
        name: 'flowBinding',
        component: () => import('@/views/workOrderFlow/flowBinding'),
        meta: { title: '流程绑定', icon: 'user' }
      },
      {
        path: '/workOrderFlow/nodeData',
        name: 'nodeData',
        component: () => import('@/views/workOrderFlow/nodeData'),
        meta: { title: '节点数据', icon: 'user' ,roles:['admin']}
      },
    ]
  },

  {
    path: '/myWorkOrder',
    component: Layout,
    redirect: '/myWorkOrder/thisWorkOrder',
    name: 'myWorkOrder',
    meta: { title: '我的工单', icon: 'people3' },
    children: [
      {
        path: '/myWorkOrder/buildWorkOrder',
        name: 'buildWorkOrder',
        component: () => import('@/views/myWorkOrder/buildWorkOrder'),
        meta: { title: '创建工单', icon: 'user' ,roles:['admin']}
      },
      {
        path: '/myWorkOrder/thisWorkOrder',
        name: 'thisWorkOrder',
        component: () => import('@/views/myWorkOrder/thisWorkOrder'),
        meta: { title: '当前工单', icon: 'user' ,roles:['admin']}
      },
      {
        path: '/myWorkOrder/historyWorkOrder',
        name: 'historyWorkOrder',
        component: () => import('@/views/myWorkOrder/historyWorkOrder'),
        meta: { title: '历史工单', icon: 'user' ,roles:['admin']}
      },

      // {
      //   path: '/flowBingdingAdd',
      //   name: 'flowBingdingAdd',
      //   hidden: true,
      //   component: () => import('@/views/myWorkOrder/searchWorkOrder'),
      //   meta: { title: '查询工单', icon: 'user' ,roles:['admin']}
      // },
    ]
  },

  {
    path: '/user',
    component: Layout,
    // redirect: '/example/table',
    redirect: '/user2',
    name: 'user',
    meta: { title: '用户管理', icon: 'people3' },
    children: [
      {
        path: '/user2',
        name: 'user2',
        component: () => import('@/views/user/user/userAll'),
        meta: { title: '用户管理', icon: 'user' }
      },
      // {
      //   path: '/adduser',
      //   name: 'adduser',
      //   component: () => import('@/views/user/user/component/header-child/adduser'),
      //   meta: { title: '新增用户', icon: 'user' ,roles:['admin']}
      // },
      // {
      //   path: '/userEdit',
      //   name: 'userEdit',
      //   component: () => import('@/views/user/user/component/body-child/userEdit'),
      //   meta: { title: '编辑用户', icon: 'user' ,roles:['admin']}
      // },
      {
        path: '/role',
        name: 'role',
        component: () => import('@/views/user/role/index'),
        meta: { title: '角色管理', icon: 'role' }
      },
      {
        path: '/framework',
        name: 'framework',
        component: () => import('@/views/user/framework/index'),
        meta: { title: '组织架构', icon: 'structure' }
      }
    ]
  },

  {
    path: '/system',
    component: Layout,
    redirect: '/system/system',
    name: 'system',
    meta: { title: '系统模块', icon: 'people3' },
    children: [
      {
        path: '/system/userGroup',
        name: 'userGroup',
        component: () => import('@/views/system/userGroup'),
        meta: { title: '用户组', icon: 'user' ,roles:['admin']}
      },
      {
        path: '/system/userJurisdiction',
        name: 'userJurisdiction',
        component: () => import('@/views/system/userJurisdiction'),
        meta: { title: '用户权限', icon: 'user' ,roles:['admin']}
      },
      {
        path: '/system/stopwatch',
        name: 'stopwatch',
        component: () => import('@/views/system/stopwatch'),
        meta: { title: '码表管理', icon: 'user' ,roles:['admin']}
      },
    ]
  },


  // {
  //   path: '/form',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'Form',
  //       component: () => import('@/views/form/index'),
  //       meta: { title: 'Form', icon: 'form' }
  //     }
  //   ]
  // },





  // {
  //   path: '/nested',
  //   component: Layout,
  //   redirect: '/nested/menu1',
  //
  //   name: 'Nested',
  //   meta: {
  //     title: 'nested',
  //     icon: 'nested'
  //   },
  //   children: [
  //     {
  //       path: 'menu1',
  //       component: () => import('@/views/nested/menu1/index'), // Parent router-view
  //       name: 'Menu1',
  //       meta: { title: 'menu1' },
  //       children: [
  //         {
  //           path: 'menu1-1',
  //           component: () => import('@/views/nested/menu1/menu1-1'),
  //           name: 'Menu1-1',
  //           meta: { title: 'menu1-1' }
  //         },
  //         {
  //           path: 'menu1-2',
  //           component: () => import('@/views/nested/menu1/menu1-2'),
  //           name: 'Menu1-2',
  //           meta: { title: 'menu1-2' },
  //           children: [
  //             {
  //               path: 'menu1-2-1',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
  //               name: 'Menu1-2-1',
  //               meta: { title: 'menu1-2-1' }
  //             },
  //             {
  //               path: 'menu1-2-2',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
  //               name: 'Menu1-2-2',
  //               meta: { title: 'menu1-2-2' }
  //             }
  //           ]
  //         },
  //         {
  //           path: 'menu1-3',
  //           component: () => import('@/views/nested/menu1/menu1-3'),
  //           name: 'Menu1-3',
  //           meta: { title: 'menu1-3' }
  //         }
  //       ]
  //     },
  //     {
  //       path: 'menu2',
  //       component: () => import('@/views/nested/menu2/index'),
  //       meta: { title: 'menu2' }
  //     }
  //   ]
  // },

  // {
  //   path: 'external-link',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
  //       meta: { title: 'externalLink', icon: 'link' }
  //     }
  //   ]
  // },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
